<?php

namespace app\common\model;

use Carbon\Carbon;
use think\Model;

class BgComments extends Model
{
    //
    protected $autoWriteTimestamp=true;

    //获取器
    public function getCreateTimeAttr($time){
        $datetime=date('Y-m-d H:i:s',$time);
        $date=new Carbon($datetime);
        return $date->diffForHumans();
    }

    public function user(){
        return $this->hasOne('Users','uid','user_id');
    }

    //获取父级user信息
    public function pname(){
        return $this->hasOne('Users','uid','pid');
    }
}
